#!/usr/bin/env Python
# -*- coding:utf-8 -*-
# unit_universal_converter.py
# author: luoxiang


# 需求：实现以下常见公制单位的相互转换：

# 温度单位:摄氏度(celsius equals)，华氏度(fahenheit equals)，开氏度(kelvin equals)

# 长度单位：公里(km)，米(m)，分米(dm)，厘米(cm)，毫米(mm)，微米(um)，纳米(nm)，皮米(pm)

# 面积单位:平方公里(km2)，公顷(hm2)，亩(mu)，平方米(m2)，平方分米(dm2)，平方厘米(cm2)，平方毫米(mm2)

# 重量单位：吨(t)，公担(q)，千克(kg)，克(Gram)，克拉(ct), 分(point), 毫克(Milligram), 微克(ug)

# 体积单位：立方米(m3)，立方分米(dm3)，立方厘米(cm3)，立方毫米(mm3)，升(l)，毫升(ml)

# 时间单位：年(yr)，周(week)，日(d)，小时(h)，分钟(minute)，秒(s)，毫秒(ms)，微秒(us)，纳秒(ns)

# 速度单位：千米/小时(km/h)，千米/秒(km/s)，米/秒(m/s)

# 功率单位：千瓦(kW)，瓦(W)，千卡/秒(kcal/s)，英制马力(hp)，米制马力(ps)，公斤·米/秒(kg·m/s)，焦耳/秒(J/s)

# 压力单位：巴(bar)，千帕(kpa)，百帕(hpa)，帕斯卡(pa)，毫巴(mbar)，标准大气压(atm)，毫米汞柱(mmhg)

# 进制单位:(0d)十进制，(0b)二进制，(0o)八进制，(0x)十六进制

# 货币单位：人民币(CNY)，美元(USD)，日元(JPY)，欧元(EUR)，英镑(GBP)，韩币(KRW)，港币(HKD)，澳元(AUD)，加拿大元(CAD)(设置实时汇率)


import time
import math
type_dict = {}
unit_dict = {}

num = 0
temp = {1: '摄氏度(C)', 2: '华氏度(F)', 3: '开氏度(K)'}
length = {1: '公里(km)', 2: '米(m)', 3: '分米(dm)', 4: '厘米(cm)',
          5: '毫米(mm)', 6: '微米(um)', 7: '纳米(nm)', 8: '皮米(pm)'}
area = {1: '平方公里(km2)', 2: '公顷(ha)', 3: '亩(mu)', 4: '平方米(m2)',
        5: '平方分米(dm2)', 6: '平方厘米(cm2)', 7: '平方毫米(mm2)'}
weight = {1: '吨(t)', 2: '公担(q)', 3: '千克(kg)', 4: '克(g)',
          5: '克拉(ct)', 6: '分(point)', 7: '毫克(mg)', 8: '微克(ug)'}
volume = {1: '立方米(m3)', 2: '立方分米(dm3)', 3: '立方厘米(cm3)',
          4: '立方毫米(mm3)', 5: '升(l)', 6: '毫升(ml)'}
times = {1: '年(yr)', 2: '周(week)',  3: '日(d)',
         4: '小时(h)', 5: '分钟(minute)', 6: '秒(s)',
         7: '毫秒(ms)', 8: '微秒(us)', 9: '纳秒(ns)'}
speed = {1: '千米/小时(km/h)', 2: '千米/秒(km/s)',
         3: '米/秒(m/s)'}
pressure = {1: '千瓦(kW)', 2: '瓦(W)', 3: '千卡/秒(kcal/s)', 4: '英制马力(hp)',
            5: '米制马力(ps)', 6: '公斤·米/秒((kg·m/s)', 7: '焦耳/秒(J/s)'}
power = {1: '巴(bar)', 2: '千帕(kpa)', 3: '百帕(hpa)', 4: '帕斯卡(pa)',
         5: '毫巴(mbar)', 6: '标准大气压(atm)', 7: '毫米汞柱(mmhg)'}
base_system = {1: '(0d)十进制', 2: '(0b)二进制', 3: '(0o)八进制', 4: '(0x)十六进制'}
currency = {1: '人民币(CNY)', 2: '美元(USD)', 3: '日元(JPY)',
            4: '欧元(EUR)', 5: '英镑(GBP)', 6: '韩币(KRW)',
            7: '港币(HKD)', 8: '澳元(AUD)', 9: '加拿大元(CAD)'}
unit_dict['temp'] = temp
unit_dict['length'] = length
unit_dict['area'] = area
unit_dict['weight'] = weight
unit_dict['volume'] = volume
unit_dict['times'] = times
unit_dict['speed'] = speed
unit_dict['pressure'] = pressure
unit_dict['power'] = power
unit_dict['base_system'] = base_system
unit_dict['currency'] = currency

type_name = '''temp,length,area,weight,volume,times,speed,
               pressure,power,base_system,currency'''
type_ch_name = '温度,长度,面积,重量,体积,时间,速度,压力,功率,进制,货币'
type_list = type_name.split(',')
type_ch_list = type_ch_name.split(',')
for x in type_list:
    num += 1
    type_dict[num] = x

print('欢迎使用万能单位转换器'.center(30, "-"))
time.sleep(1)
print('转换器提供11种公制转换类型'.center(30, "-"))
time.sleep(1)
print('1.温度 2.长度 3.面积 4.重量 5.体积 6.时间 7.速度 8.压力 9.功率 10.进制 11.货币 0.退出 ')
time.sleep(1)
choose = input('请输入对应数字：')

while choose == '':
    print('不能为空！')
    choose = input('请输入对应数字：')
    continue     

choose = int(choose)

while choose == '0':  # 退出
    break

# 温度单位互转
if choose == 1:
    
    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 1:

    value01 = input(f'请输入{type_ch_list[choose -1]}(示例:1C, 2F, 3K):')

    if value01 in ['C', 'F', 'K']:
        print('单位前不能为空')
        continue
    
    # 摄氏温度转其他
    if value01[value01.find('C'):] == 'C':
        TC = value01[:value01.find('C')]
        TF = (9/5) * float(TC) + 32
        TK = float(TC) + 273.15
        print(f'{unit_dict[type_dict[choose]][2]}: {float(TF)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(TK)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 华氏温度转其他
    if value01[value01.find('F'):] == 'F':
        TF = value01[:value01.find('F')]
        TC = (5/9) * (float(TF) - 32)
        TK = (5/9) * (float(TF) - 32) + 273.15
        print(f'{unit_dict[type_dict[choose]][1]}: {float(TC)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(TK)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 开氏温度转其他
    if value01[value01.find('K'):] == 'K':
        TK = value01[:value01.find('K')]
        TC = float(TK) - 273.15
        TF = (9/5) * (float(TK) - 273.15) + 32
        print(f'{unit_dict[type_dict[choose]][1]}: {float(TC)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(TF)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')

# 长度单位互转
if choose == 2:

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 2:

    value02 = input(f'请输入{type_ch_list[choose -1]}(示例:1km, 2m, 3cm):')

    if value02 in ['km', 'm', 'dm','cm', 'mm', 'um', 'nm', 'pm']:
        print('单位前不能为空!')
        continue

    # 公里转其他
    if value02[value02.find('km'):] == 'km':
        km = value02[:value02.find('km')]
        m = float(km) * 10**3
        dm = float(km) * 10**4
        cm = float(km) * 10**5
        mm = float(km) * 10**6
        um = float(km) * 10**9
        nm = float(km) * 10**12
        pm = float(km) * 10**15
        print(f'{unit_dict[type_dict[choose]][2]}: {float(m)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(dm)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(cm)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mm)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(um)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(nm)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(pm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 分米转其他
    if value02[value02.find('dm'):] == 'dm':
        dm = value02[:value02.find('dm')]
        km = float(dm) * 10**(-4)
        m = float(dm) * 10**(-1)
        cm = float(dm) * 10
        mm = float(dm) * 10**2
        um = float(dm) * 10**5
        nm = float(dm) * 10**8
        pm = float(dm) * 10**11
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(m)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(cm)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mm)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(um)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(nm)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(pm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 厘米转其他
    if value02[value02.find('cm'):] == 'cm':
        cm = value02[:value02.find('cm')]
        km = float(cm) * pow(10, -5)
        m = float(cm) * 10**(-2)
        dm = float(cm) * 10**(-1)
        mm = float(cm) * 10
        um = float(cm) * 10**4
        nm = float(cm) * 10**7
        pm = float(cm) * 10**10
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(m)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(dm)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mm)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(um)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(nm)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(pm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 毫米转其他
    if value02[value02.find('mm'):] == 'mm':
        mm = value02[:value02.find('mm')]
        km = float(mm) * pow(10, -6)
        m = float(mm) * 10**(-3)
        dm = float(mm) * 10**(-2)
        cm = float(mm) * 10**(-1)
        um = float(mm) * 10**3
        nm = float(mm) * 10**6
        pm = float(mm) * 10**9
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(m)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(dm)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(cm)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(um)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(nm)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(pm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 微米转其他
    if value02[value02.find('um'):] == 'um':
        um = value02[:value02.find('um')]
        km = float(um) * pow(10, -9)
        m = float(um) * 10**(-6)
        dm = float(um) * 10**(-5)
        cm = float(um) * 10**(-4)
        mm = float(um) * 10**(-3)
        nm = float(um) * 10**3
        pm = float(um) * 10**6
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(m)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(dm)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(cm)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mm)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(nm)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(pm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 纳米转其他
    if value02[value02.find('nm'):] == 'nm':
        nm = value02[:value02.find('nm')]
        km = float(nm) * pow(10, -12)
        m = float(nm) * 10**(-9)
        dm = float(nm) * 10**(-8)
        cm = float(nm) * 10**(-7)
        mm = float(nm) * 10**(-6)
        um = float(nm) * 10**(-3)
        pm = float(nm) * 10**3
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(m)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(dm)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(cm)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mm)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(um)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(pm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 皮米转其他
    if value02[value02.find('pm'):] == 'pm':
        pm = value02[:value02.find('pm')]
        km = float(pm) * pow(10, -15)
        m = float(pm) * 10**(-12)
        dm = float(pm) * 10**(-11)
        cm = float(pm) * 10**(-10)
        mm = float(pm) * 10**(-9)
        um = float(pm) * 10**(-6)
        nm = float(pm) * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(m)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(dm)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(cm)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mm)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(um)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(nm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 米转其他
    if value02[value02.find('m'):] == 'm':
        m = value02[:value02.find('m')]
        km = float(m) * 10**(-3)
        dm = float(m) * 10
        cm = float(m) * 100
        mm = float(m) * 10**3
        um = float(m) * 10**6
        nm = float(m) * 10**9
        pm = float(m) * 10**12
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(dm)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(cm)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mm)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(um)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(nm)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(pm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')
    
# 面积单位互转
if choose == 3:

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 3:

    value03 = input(f'请输入{type_ch_list[choose -1]}(示例:1km2, 2ha, 3cm2):')

    if value03 in ['km2', 'ha', 'mu','m2', 'dm2', 'cm2', 'mm2']:
        print('单位前不能为空!')
        continue

    # 平方公里转其他
    if value03[value03.find('km2'):] == 'km2':
        km2 = value03[:value03.find('km2')]
        ha = float(km2) * 10**2
        mu = float(km2) * 15 * 10**2
        m2 = float(km2) * 10**6
        dm2 = float(km2) * 10**8
        cm2 = float(km2) * 10**10
        mm2 = float(km2) * 10**12
        print(f'{unit_dict[type_dict[choose]][2]}: {float(ha)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(mu)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(m2)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(dm2)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(cm2)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mm2)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 公顷转其他
    if value03[value03.find('ha'):] == 'ha':
        ha = value03[:value03.find('ha')]
        km2 = float(ha) * 10**(-2)
        mu = float(ha) * 15
        m2 = float(ha) * 10**4
        dm2 = float(ha) * 10**6
        cm2 = float(ha) * 10**8
        mm2 = float(ha) * 10**10
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km2)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(mu)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(m2)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(dm2)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(cm2)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mm2)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 亩转其他
    if value03[value03.find('mu'):] == 'mu':
        mu = value03[:value03.find('mu')]
        km2 = float(mu) * (1/15) * 10**(-2)
        ha = float(mu) * (1/15)
        m2 = float(mu) * (1/15) * 10**4
        dm2 = float(mu) * (1/15) * 10**6
        cm2 = float(mu) * (1/15) * 10**8
        mm2 = float(mu) * (1/15) * 10**10
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km2)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(ha)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(m2)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(dm2)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(cm2)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mm2)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 平方分米转其他
    if value03[value03.find('dm2'):] == 'dm2':
        dm2 = value03[:value03.find('dm2')]
        km2 = float(dm2) * 10**(-8)
        ha = float(dm2) * 10**(-6)
        mu = float(dm2) * 15 * 10**(-6)
        m2 = float(dm2) * 10**(-2)
        cm2 = float(dm2) * 10**2
        mm2 = float(dm2) * 10**4
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km2)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(ha)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(mu)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(m2)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(cm2)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mm2)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 平方厘米转其他
    if value03[value03.find('cm2'):] == 'cm2':
        cm2 = value03[:value03.find('cm2')]
        km2 = float(cm2) * 10**(-10)
        ha = float(cm2) * 10**(-8)
        mu = float(cm2) * 15 * 10**(-8)
        m2 = float(cm2) * 10**(-4)
        dm2 = float(cm2) * 10**(-2)
        mm2 = float(cm2) * 10**2
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km2)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(ha)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(mu)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(m2)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(dm2)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mm2)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 平方毫米转其他
    if value03[value03.find('mm2'):] == 'mm2':
        mm2 = value03[:value03.find('mm2')]
        km2 = float(mm2) * 10**(-12)
        ha = float(mm2) * 10**(-10)
        mu = float(mm2) * 15 * 10**(-10)
        m2 = float(mm2) * 10**(-6)
        dm2 = float(mm2) * 10**(-4)
        cm2 = float(mm2) * 10**(-2)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km2)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(ha)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(mu)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(m2)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(dm2)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(cm2)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 平方米转其他
    if value03[value03.find('m2'):] == 'm2':
        m2 = value03[:value03.find('m2')]
        km2 = float(m2) * 10**(-6)
        ha = float(m2) * 10**(-4)
        mu = float(m2) * 15 * 10**(-4)
        dm2 = float(m2) * 10**2
        cm2 = float(m2) * 10**4
        mm2 = float(m2) * 10**6
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km2)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(ha)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(mu)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(dm2)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(cm2)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mm2)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')

# 重量单位互转
if choose == 4:

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 4:

    value04 = input(f'请输入{type_ch_list[choose -1]}(示例:1t, 2kg, 3q):')

    if value04 in ['t', 'q', 'kg', 'g', 'ct', 'point', 'mg', 'ug']:
        print('单位前不能为空!')
        continue

    # 公担转其他
    if value04[value04.find('q'):] == 'q':
        q = value04[:value04.find('q')]
        t = float(q) * 10**(-1)
        kg = float(q) * 10**2
        g = float(q) * 10**5
        ct = float(q) * 5 * 10**5
        point = float(q) * 5 * 10**7
        mg = float(q) * 10**8
        ug = float(q) * 10**11
        print(f'{unit_dict[type_dict[choose]][1]}: {float(t)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kg)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(g)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ct)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(point)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mg)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(ug)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 千克转其他
    if value04[value04.find('kg'):] == 'kg':
        kg = value04[:value04.find('kg')]
        t = float(kg) * 10**(-3)
        q = float(kg) * 10**(-2)
        g = float(kg) * 10**3
        ct = float(kg) * 5 * 10**3
        point = float(kg) * 5 * 10**5
        mg = float(kg) * 10**6
        ug = float(kg) * 10**9
        print(f'{unit_dict[type_dict[choose]][1]}: {float(t)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(q)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(g)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ct)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(point)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mg)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(ug)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 克拉转其他
    if value04[value04.find('ct'):] == 'ct':
        ct = value04[:value04.find('ct')]
        t = float(ct) * 2 * 10**(-7)
        q = float(ct) * 2 * 10**(-6)
        kg = float(ct) * 2 * 10**(-4)
        g = float(ct) * 2 * 10**(-1)
        point = float(ct) * 10**2
        mg = float(ct) * 2 * 10**2
        ug = float(ct) * 2 * 10**5
        print(f'{unit_dict[type_dict[choose]][1]}: {float(t)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(q)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kg)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(g)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(point)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mg)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(ug)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 分转其他
    if value04[value04.find('point'):] == 'point':
        point = value04[:value04.find('point')]
        t = float(point) * 2 * 10**(-9)
        q = float(point) * 2 * 10**(-8)
        kg = float(point) * 2 * 10**(-6)
        g = float(point) * 2 * 10**(-3)
        ct = float(point) * 10**(-2)
        mg = float(point) * 2
        ug = float(point) * 2 * 10**3
        print(f'{unit_dict[type_dict[choose]][1]}: {float(t)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(q)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kg)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(g)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ct)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mg)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(ug)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 毫克转其他
    if value04[value04.find('mg'):] == 'mg':
        mg = value04[:value04.find('mg')]
        t = float(mg) * 10**(-9)
        q = float(mg) * 10**(-8)
        kg = float(mg) * 10**(-6)
        g = float(mg) * 10**(-3)
        ct = float(mg) * 5 * 10**(-3)
        point = float(mg) * 5 * 10**(-1)
        ug = float(mg) * 10**3
        print(f'{unit_dict[type_dict[choose]][1]}: {float(t)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(q)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kg)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(g)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ct)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(point)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(ug)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 微克转其他
    if value04[value04.find('ug'):] == 'ug':
        ug = value04[:value04.find('ug')]
        t = float(ug) * 10**(-12)
        q = float(ug) * 10**(-11)
        kg = float(ug) * 10**(-9)
        g = float(ug) * 10**(-6)
        ct = float(ug) * 5 * 10**(-6)
        point = float(ug) * 5 * 10**(-4)
        mg = float(ug) * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(t)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(q)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kg)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(g)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ct)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(point)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mg)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 克转其他
    if value04[value04.find('g'):] == 'g':
        g = value04[:value04.find('g')]
        t = float(g) * 10**(-6)
        q = float(g) * 10**(-5)
        kg = float(g) * 10**(-3)
        ct = float(g) * 5
        point = float(g) * 5 * 10**2
        mg = float(g) * 10**3
        ug = float(g) * 10**6
        print(f'{unit_dict[type_dict[choose]][1]}: {float(t)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(q)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kg)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ct)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(point)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mg)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(ug)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 吨转其他
    if value04[value04.find('t'):] == 't':
        t = value04[:value04.find('t')]
        q = float(t) * 10
        kg = float(t) * 10**3
        g = float(t) * 10**6
        ct = float(t) * 5 * 10**6
        point = float(t) * 5 * 10**8
        mg = float(t) * 10**9
        ug = float(t) * 10**12
        print(f'{unit_dict[type_dict[choose]][2]}: {float(q)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kg)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(g)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ct)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(point)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mg)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(ug)}')
        time.sleep(1)
        print('是否继续转换(y/n)')
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')

# 体积单位互转
if choose == 5:

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 5:

    value05 = input(f'请输入{type_ch_list[choose -1]}(示例:1m3, 2l, 3ml):')

    if value05 in ['m3', 'dm3', 'cm3', 'mm3', 'l', 'ml']:
        print('单位前不能为空!')
        continue

    # 立方分米转其他
    if value05[value05.find('dm3'):] == 'dm3':
        dm3 = value05[:value05.find('dm3')]
        m3 = float(dm3) * 10**(-3)
        cm3 = float(dm3) * 10**3
        mm3 = float(dm3) * 10**6
        l = float(dm3)
        ml = float(dm3) * 10**3
        print(f'{unit_dict[type_dict[choose]][1]}: {float(m3)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(cm3)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(mm3)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(l)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(ml)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 立方厘米转其他
    if value05[value05.find('cm3'):] == 'cm3':
        cm3 = value05[:value05.find('cm3')]
        m3 = float(cm3) * 10**(-6)
        dm3 = float(cm3) * 10**(-3)
        mm3 = float(cm3) * 10**3
        l = float(cm3) * 10**(-3)
        ml = float(cm3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(m3)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(dm3)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(mm3)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(l)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(ml)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 立方毫米转其他
    if value05[value05.find('mm3'):] == 'mm3':
        mm3 = value05[:value05.find('mm3')]
        m3 = float(mm3) * 10**(-9)
        dm3 = float(mm3) * 10**(-6)
        cm3 = float(mm3) * 10**(-3)
        l = float(mm3) * 10**(-6)
        ml = float(mm3) * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(m3)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(dm3)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(cm3)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(l)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(ml)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 毫升转其他
    if value05[value05.find('ml'):] == 'ml':
        ml = value05[:value05.find('ml')]
        m3 = float(ml) * 10**(-6)
        dm3 = float(ml) * 10**(-3)
        cm3 = float(ml)
        mm3 = float(ml) * 10**3
        l = float(ml) * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(m3)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(dm3)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(cm3)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(mm3)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(l)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 升转其他
    if value05[value05.find('l'):] == 'l':
        l = value05[:value05.find('l')]
        m3 = float(l) * 10**(-3)
        dm3 = float(l)
        cm3 = float(l) * 10**3
        mm3 = float(l) * 10**6
        ml = float(l) * 10**3
        print(f'{unit_dict[type_dict[choose]][1]}: {float(m3)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(dm3)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(cm3)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(mm3)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(ml)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 立方米转其他
    if value05[value05.find('m3'):] == 'm3':
        m3 = value05[:value05.find('m3')]
        dm3 = float(m3) * 10**3
        cm3 = float(m3) * 10**6
        mm3 = float(m3) * 10**9
        l = float(m3) * 10**3
        ml = float(m3) * 10**6
        print(f'{unit_dict[type_dict[choose]][2]}: {float(dm3)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(cm3)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(mm3)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(l)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(ml)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')

# 时间单位互转
if choose == 6:
    
    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 6:

    value06 = input(f'请输入{type_ch_list[choose -1]}(示例:1yr, 4week, 30min):')

    if value06 in ['yr', 'week', 'd', 'h', 'minute', 's', 'ms', 'us', 'ns']:
        print('单位前不能为空!')
        continue

    # 年转其他
    if value06[value06.find('yr'):] == 'yr':
        yr = value06[:value06.find('yr')]
        week = float(yr) * (365/7)
        d = float(yr) * 365
        h = float(yr) * 365 * 24
        minute = float(yr) * 365 * 24 * 60
        s = float(yr) * 365 * 24 * 60**2
        ms = float(yr) * 365 * 24 * 60**2 * 10**3
        us = float(yr) * 365 * 24 * 60**2 * 10**6
        ns = float(yr) * 365 * 24 * 60**2 * 10**9
        print(f'{unit_dict[type_dict[choose]][2]}: {float(week)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(d)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(h)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(minute)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(ms)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(us)},',
              f'{unit_dict[type_dict[choose]][9]}: {float(ns)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 周转其他
    if value06[value06.find('week'):] == 'week':
        week = value06[:value06.find('week')]
        yr = float(week) * (7/365)
        d = float(week) * 7
        h = float(week) * 7 * 24
        minute = float(week) * 7 * 24 * 60
        s = float(week) * 7 * 24 * 60**2
        ms = float(week) * 7 * 24 * 60**2 * 10**3
        us = float(week) * 7 * 24 * 60**2 * 10**6
        ns = float(week) * 7 * 24 * 60**2 * 10**9
        print(f'{unit_dict[type_dict[choose]][1]}: {float(yr)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(d)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(h)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(minute)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(ms)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(us)},',
              f'{unit_dict[type_dict[choose]][9]}: {float(ns)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 天转其他
    if value06[value06.find('d'):] == 'd':
        d = value06[:value06.find('d')]
        yr = float(d) * (1/365)
        week = float(d) * (1/7)
        h = float(d) * 24
        minute = float(d) * 24 * 60
        s = float(d) * 24 * 60**2
        ms = float(d) * 24 * 60**2 * 10**3
        us = float(d) * 24 * 60**2 * 10**6
        ns = float(d) * 24 * 60**2 * 10**9
        print(f'{unit_dict[type_dict[choose]][1]}: {float(yr)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(week)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(h)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(minute)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(ms)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(us)},',
              f'{unit_dict[type_dict[choose]][9]}: {float(ns)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 小时转其他
    if value06[value06.find('h'):] == 'h':
        h = value06[:value06.find('h')]
        yr = float(h) * 1/(365 * 24)
        week = float(h) * 1/(7 * 24)
        d = float(h) * 1/24
        minute = float(h) * 60
        s = float(h) * 60**2
        ms = float(h) * 60**2 * 10**3
        us = float(h) * 60**2 * 10**6
        ns = float(h) * 60**2 * 10**9
        print(f'{unit_dict[type_dict[choose]][1]}: {float(yr)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(week)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(d)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(minute)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(ms)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(us)},',
              f'{unit_dict[type_dict[choose]][9]}: {float(ns)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 分钟转其他
    if value06[value06.find('minute'):] == 'minute':
        minute = value06[:value06.find('minute')]
        yr = float(minute) * 1/(365 * 24 * 60)
        week = float(minute) * 1/(7 * 24 * 60)
        d = float(minute) * 1/(24 * 60)
        h = float(minute) * 1/60
        s = float(minute) * 60
        ms = float(minute) * 60 * 10**3
        us = float(minute) * 60 * 10**6
        ns = float(minute) * 60 * 10**9
        print(f'{unit_dict[type_dict[choose]][1]}: {float(yr)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(week)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(d)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(h)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(ms)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(us)},',
              f'{unit_dict[type_dict[choose]][9]}: {float(ns)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 毫秒转其他
    if value06[value06.find('ms'):] == 'ms':
        ms = value06[:value06.find('ms')]
        yr = float(ms) * 1/(365 * 24 * 60**2 * 10**3)
        week = float(ms) * 1/(7 * 24 * 60**2 * 10**3)
        d = float(ms) * 1/(24 * 60**2 * 10**3)
        h = float(ms) * 1/(60**2 * 10**3)
        minute = float(ms) * 1/(60 * 10**3)
        s = float(ms) * 10**(-3)
        us = float(ms) * 10**3
        ns = float(ms) * 10**6
        print(f'{unit_dict[type_dict[choose]][1]}: {float(yr)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(week)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(d)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(h)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(minute)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(s)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(us)},',
              f'{unit_dict[type_dict[choose]][9]}: {float(ns)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 微秒转其他
    if value06[value06.find('us'):] == 'us':
        us = value06[:value06.find('us')]
        yr = float(us) * 1/(365 * 24 * 60**2 * 10**6)
        week = float(us) * 1/(7 * 24 * 60**2 * 10**6)
        d = float(us) * 1/(24 * 60**2 * 10**6)
        h = float(us) * 1/(60**2 * 10**6)
        minute = float(us) * 1/(60 * 10**6)
        s = float(us) * 10**(-6)
        ms = float(us) * 10**(-3)
        ns = float(us) * 10**3
        print(f'{unit_dict[type_dict[choose]][1]}: {float(yr)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(week)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(d)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(h)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(minute)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(ms)},',
              f'{unit_dict[type_dict[choose]][9]}: {float(ns)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 纳秒转其他
    if value06[value06.find('ns'):] == 'ns':
        ns = value06[:value06.find('ns')]
        yr = float(ns) * 1/(365 * 24 * 60**2 * 10**9)
        week = float(ns) * 1/(7 * 24 * 60**2 * 10**9)
        d = float(ns) * 1/(24 * 60**2 * 10**9)
        h = float(ns) * 1/(60**2 * 10**9)
        minute = float(ns) * 1/(60 * 10**9)
        s = float(ns) * 10**(-9)
        ms = float(ns) * 10**(-6)
        us = float(ns) * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(yr)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(week)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(d)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(h)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(minute)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(ms)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(us)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 秒转其他
    if value06[value06.find('s'):] == 's':
        s = value06[:value06.find('s')]
        yr = float(s) * 1/(365 * 24 * 60**2)
        week = float(s) * 1/(7 * 24 * 60**2)
        d = float(s) * 1/(24 * 60**2)
        h = float(s) * 1/(60**2)
        minute = float(s) * 1/60
        ms = float(s) * 10**3
        us = float(s) * 10**6
        ns = float(s) * 10**9
        print(f'{unit_dict[type_dict[choose]][1]}: {float(yr)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(week)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(d)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(h)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(minute)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(ms)},',
              f'{unit_dict[type_dict[choose]][8]}: {float(us)},',
              f'{unit_dict[type_dict[choose]][9]}: {float(ns)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')

# 速度单位互转
if choose == 7:

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 7:

    value07 = input(f'请输入{type_ch_list[choose -1]}(示例:1km/h, 3km/s, 10m/s):')

    if value07 in ['km/h', 'km/s', 'm/s']:
        print('单位前不能为空!')
        continue
    
    # 千米/小时转其他
    if value07[value07.find('km/h'):] == 'km/h':
        km_h = value07[:value07.find('km/h')]
        km_s = float(km_h) * 1/60**2
        m_s = float(km_h) * 1/3.6
        print(f'{unit_dict[type_dict[choose]][2]}: {float(km_s)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(m_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break    
    
    # 千米/秒转其他
    if value07[value07.find('km/s'):] == 'km/s':
        km_s = value07[:value07.find('km/s')]
        km_h = float(km_s) * 60**2
        m_s = float(km_s) * 10**3
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km_h)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(m_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 米/秒转其他
    if value07[value07.find('m/s'):] == 'm/s':
        m_s = value07[:value07.find('m/s')]
        km_h = float(m_s) * 3.6
        km_s = float(m_s) * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(km_h)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(km_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')

# 功率单位互转
if choose == 8:

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 8:

    value08 = input(f'请输入{type_ch_list[choose -1]}(示例:1kW, 3kcal/s, 10ps):')

    if value08 in ['kW', 'W', 'kcal/s', 'hp', 'ps', 'kg·m/s', 'J/s']:
        print('单位前不能为空!')
        continue

    # 千瓦转其他
    if value08[value08.find('kW'):] == 'kW':
        kW = value08[:value08.find('kW')]
        W = float(kW) * 10**3
        kcal_s = float(kW) * 0.239
        hp = float(kW) * 1.34
        ps = float(kW) * 1.36
        kgm_s = float(kW) * 102
        J_s = float(kW) * 10**3
        print(f'{unit_dict[type_dict[choose]][2]}: {float(W)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kcal_s)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(hp)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ps)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(kgm_s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(J_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 瓦转其他
    if value08[value08.find('W'):] == 'W':
        W = value08[:value08.find('W')]
        kW = float(W) * 10**(-3)
        kcal_s = float(W) * 0.239 * 10**(-3)
        hp = float(W) * 1.34 * 10**(-3)
        ps = float(W) * 1.36 * 10**(-3)
        kgm_s = float(W) * 102 * 10**(-3)
        J_s = float(W)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(kW)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kcal_s)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(hp)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ps)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(kgm_s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(J_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 千卡/秒转其他
    if value08[value08.find('kcal/s'):] == 'kcal/s':
        kcal_s = value08[:value08.find('kcal/s')]
        kW = float(kcal_s) * 1/0.239
        W = float(kcal_s) * 1/0.239 * 10**3
        hp = float(kcal_s) * 5.61
        ps = float(kcal_s) * 5.69
        kgm_s = float(kcal_s) * 426.66
        J_s = float(kcal_s) * 1/0.239 * 10**3
        print(f'{unit_dict[type_dict[choose]][1]}: {float(kW)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(W)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(hp)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ps)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(kgm_s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(J_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 英制马力转其他
    if value08[value08.find('hp'):] == 'hp':
        hp = value08[:value08.find('hp')]
        kW = float(hp) * 745.7 * 10**(-3)
        W = float(hp) * 745.7
        kcal_s = float(hp) * 1/5.61
        ps = float(hp) * 5.69/5.61
        kgm_s = float(hp) * 76
        J_s = float(hp) * 745.7
        print(f'{unit_dict[type_dict[choose]][1]}: {float(kW)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(W)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kcal_s)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ps)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(kgm_s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(J_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 米制马力转其他
    if value08[value08.find('ps'):] == 'ps':
        ps = value08[:value08.find('ps')]
        kW = float(ps) * 735.5 * 10**(-3)
        W = float(ps) * 735.5
        kcal_s = float(ps) * 1/5.69
        hp = float(ps) * 5.61/5.69
        kgm_s = float(ps) * 75
        J_s = float(ps) * 735.5
        print(f'{unit_dict[type_dict[choose]][1]}: {float(kW)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(W)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kcal_s)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(hp)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(kgm_s)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(J_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 公斤·米/秒转其他
    if value08[value08.find('kg·m/s'):] == 'kg·m/s':
        kgm_s = value08[:value08.find('kg·m/s')]
        kW = float(kgm_s) * 9.8 * 10**(-3)
        W = float(kgm_s) * 9.8
        kcal_s = float(kgm_s) * 1/426.66
        hp = float(kgm_s) * 1/76
        ps = float(kgm_s) * 1/75
        J_s = float(kgm_s) * 9.8
        print(f'{unit_dict[type_dict[choose]][1]}: {float(kW)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(W)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kcal_s)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(hp)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ps)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(J_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 焦耳/秒转其他
    if value08[value08.find('J/s'):] == 'J/s':
        J_s = value08[:value08.find('J/s')]
        kW = float(J_s) * 10**(-3)
        W = float(J_s)
        kcal_s = float(J_s) * 1/(426.66 * 9.8)
        hp = float(J_s) * 1/745.7
        ps = float(J_s) * 1/735.5
        kgm_s = float(J_s) * 102 * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(kW)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(W)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(kcal_s)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(hp)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(ps)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(kgm_s)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')

# 压力单位互转
if choose == 9:

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 9:

    value09 = input(f'请输入{type_ch_list[choose -1]}(示例:1bar, 3hpa, 10mmhg):')

    if value09 in ['bar', 'kpa', 'hpa', 'pa', 'mbar', 'atm', 'mmhg']:
        print('单位前不能为空!')
        continue

    # 毫巴转其他
    if value09[value09.find('mbar'):] == 'mbar':
        mbar = value09[:value09.find('mbar')]
        bar = float(mbar) * 10**(-3)
        kpa = float(mbar) * 10**(-1)
        hpa = float(mbar)
        pa = float(mbar) * 10**2
        atm = float(mbar) * 0.987 * 10**(-3)
        mmhg = float(mbar) * 750.1 * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(bar)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(kpa)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(hpa)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(pa)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(atm)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mmhg)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 巴转其他
    if value09[value09.find('bar'):] == 'bar':
        bar = value09[:value09.find('bar')]
        kpa = float(bar) * 10**2
        hpa = float(bar) * 10**3
        pa = float(bar) * 10**5
        mbar = float(bar) * 10**3
        atm = float(bar) * 0.987
        mmhg = float(bar) * 750.1
        print(f'{unit_dict[type_dict[choose]][2]}: {float(kpa)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(hpa)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(pa)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mbar)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(atm)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mmhg)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 千帕转其他
    if value09[value09.find('kpa'):] == 'kpa':
        kpa = value09[:value09.find('kpa')]
        bar = float(kpa) * 10**(-2)
        hpa = float(kpa) * 10
        pa = float(kpa) * 10**3
        mbar = float(kpa) * 10
        atm = float(kpa) * 0.987 * 10**(-2)
        mmhg = float(kpa) * 750.1 * 10**(-2)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(bar)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(hpa)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(pa)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mbar)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(atm)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mmhg)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 百帕转其他
    if value09[value09.find('hpa'):] == 'hpa':
        hpa = value09[:value09.find('hpa')]
        bar = float(hpa) * 10**(-3)
        kpa = float(hpa) * 10**(-1)
        pa = float(hpa) * 10**2
        mbar = float(hpa)
        atm = float(hpa) * 0.987 * 10**(-3)
        mmhg = float(hpa) * 750.1 * 10**(-3)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(bar)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(kpa)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(pa)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mbar)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(atm)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mmhg)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 帕斯卡转其他
    if value09[value09.find('pa'):] == 'pa':
        pa = value09[:value09.find('pa')]
        bar = float(pa) * 10**(-5)
        kpa = float(pa) * 10**(-3)
        hpa = float(pa) * 10**(-2)
        mbar = float(pa) * 10**(-2)
        atm = float(pa) * 9.87 * 10**(-6)
        mmhg = float(pa) * 750.1 * 10**(-5)
        print(f'{unit_dict[type_dict[choose]][1]}: {float(bar)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(kpa)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(hpa)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mbar)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(atm)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mmhg)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break   

    # 标准大气压转其他
    if value09[value09.find('atm'):] == 'atm':
        atm = value09[:value09.find('atm')]
        bar = float(atm) * 101325 * 10**(-5)
        kpa = float(atm) * 101325 * 10**(-3)
        hpa = float(atm) * 101325 * 10**(-2)
        pa = float(atm) * 101325
        mbar = float(atm) * 101325 * 10**(-2)
        mmhg = float(atm) * 760
        print(f'{unit_dict[type_dict[choose]][1]}: {float(bar)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(kpa)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(hpa)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(pa)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mbar)},',
              f'{unit_dict[type_dict[choose]][7]}: {float(mmhg)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    
    # 毫米汞柱转其他
    if value09[value09.find('mmhg'):] == 'mmhg':
        mmhg = value09[:value09.find('mmhg')]
        bar = float(mmhg) * 133.3223684 * 10**(-5)
        kpa = float(mmhg) * 133.3223684 * 10**(-3)
        hpa = float(mmhg) * 133.3223684 * 10**(-2)
        pa = float(mmhg) * 133.3223684
        mbar = float(mmhg) * 133.3223684 * 10**(-2)
        atm = float(mmhg) * 1/760
        print(f'{unit_dict[type_dict[choose]][1]}: {float(bar)},',
              f'{unit_dict[type_dict[choose]][2]}: {float(kpa)},',
              f'{unit_dict[type_dict[choose]][3]}: {float(hpa)},',
              f'{unit_dict[type_dict[choose]][4]}: {float(pa)},',
              f'{unit_dict[type_dict[choose]][5]}: {float(mbar)},',
              f'{unit_dict[type_dict[choose]][6]}: {float(atm)}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break   
    print('格式不正确！')

# 进制单位互转
if choose == 10:

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])

while choose == 10:
    value10 = input(f'请输入{type_ch_list[choose -1]}(示例:0d100, 0b11001, 0x1a58:')

    if value10 in ['0d', '0b', '0o', '0x']:
        print('前缀后不能为空!')
        continue

    # 十进制转其他
    if value10[:value10.find('0d') +2] == '0d':
        ten = int(value10[value10.find('0d') +2:])
        two = bin(ten)
        two.replace('0b', '')
        eight = oct(ten)
        eight.replace('0o', '')
        sixteen = hex(ten)
        sixteen.replace('0x', '')
        print(f'{unit_dict[type_dict[choose]][2]}: {two},',
              f'{unit_dict[type_dict[choose]][3]}: {eight},',
              f'{unit_dict[type_dict[choose]][4]}: {sixteen}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 二进制转其他
    if value10[:value10.find('0b') +2] == '0b':
        two = value10[value10.find('0b') +2:]
        ten = int(two, 2)
        eight = oct(ten)
        eight.replace('0o', '')
        sixteen = hex(ten)
        sixteen.replace('0x', '')
        print(f'{unit_dict[type_dict[choose]][1]}: {ten},',
              f'{unit_dict[type_dict[choose]][3]}: {eight},',
              f'{unit_dict[type_dict[choose]][4]}: {sixteen}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 八进制转其他
    if value10[:value10.find('0o') +2] == '0o':
        eight = value10[value10.find('0o') +2:]
        ten = int(eight, 8)
        two = bin(ten)
        two.replace('0b', '')
        sixteen = hex(ten)
        sixteen.replace('0x', '')
        print(f'{unit_dict[type_dict[choose]][1]}: {ten},',
              f'{unit_dict[type_dict[choose]][2]}: {two},',
              f'{unit_dict[type_dict[choose]][4]}: {sixteen}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break

    # 十六进制转其他
    if value10[:value10.find('0x') +2] == '0x':
        two = value10[value10.find('0x') +2:]
        ten = int(two, 16)
        two = bin(ten)
        two.replace('0b', '')
        eight = oct(ten)
        eight.replace('0x', '')
        print(f'{unit_dict[type_dict[choose]][1]}: {ten},',
              f'{unit_dict[type_dict[choose]][2]}: {two},',
              f'{unit_dict[type_dict[choose]][3]}: {eight}')
        time.sleep(1)
        print('是否继续转换(y/n)')  #判断是否继续转换
        is_continue = input('')
        if is_continue == 'y':
            continue
        else:
            break
    print('格式不正确！')

# 货币单位互转
# 人民币(CNY)，美元(USD)，日元(JPY)，欧元(EUR)，英镑(GBP)，韩币(KRW)，港币(HKD)，澳元(AUD)，加拿大元(CAD)
if choose == 11 :

    print(f'您选择的{type_ch_list[choose -1]}有以下单位可供互转')
    time.sleep(1)
    print(unit_dict[type_dict[choose]])
    time.sleep(1)
    print('正在优化开发中。。。')
# TODO：爬虫实时抓取常用货币之间的汇率
# while choose == 11 :

#     value11 = input(f'请输入{type_ch_list[choose -1]}(示例:100CNY, 50USD, 10EUR):')

#     if value11 in ['CNY', 'USD', 'JPY', 'EUR', 'GBP', 'KRW', 'HKD', 'AUD', 'CAD']:
#         print('单位前不能为空!')
#         continue

    
else:
    print('谢谢使用！')

    
